﻿@model CompanyInfoIM
@{
    ViewBag.Title = "公司资料";
    ViewBag.PageTitle = ViewBag.Title + "_常规设置";
}

@section Header{
    <link href="~/plugins/SigFinder/SigFinder.min.css" rel="stylesheet" />
    <link href="~/plugins/webuploader/webuploader.css" rel="stylesheet" />
}


    <div class="panel panel-default">
        <div class="panel-body">
            <!-- Nav tabs -->
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">联系方式</a></li>
                <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">网络社交</a></li>
            </ul>

            <!-- Tab panes -->
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="home">
                    <br/>
                    @Html.Partial("_Contact", Model.Contact)
                </div>
                <div role="tabpanel" class="tab-pane" id="profile">
                    <br />
                    @Html.Partial("_Social",Model.Social)
                </div>
            </div>

        </div>
    </div>



    <!-- Modal 百度地图 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel"><span class="glyphicon glyphicon-map-marker"></span> 百度地图坐标拾取</h4>
            </div>
            <div class="modal-body">
                <div id="allmap" style="width:100%;height:450px;"></div>
                <span class="help-block">
                    *点击地图，会自动获取所点击目标的坐标。
                </span>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
<!-- end main container -->

@Html.Action("PopuFinder", "File")
@section footer {
    @Scripts.Render("~/bundles/jqueryvalWithBootstrap")
<script src="/Plugins/webuploader/webuploader.min.js"></script>
<script src="/Plugins/SigFinder/FileManager.js"></script>

<script src="http://api.map.baidu.com/api?v=2.0&ak=G7h0sKsr60IFU3OrHRmKTRzD"></script>

<script>

    // 百度地图API功能
    var map = new BMap.Map("allmap");

    map.enableScrollWheelZoom(true);
    map.addControl(new BMap.NavigationControl());

    var currentPoint = $('#Coordinate').val();
    if (currentPoint.length > 0) {
        var pt = currentPoint.split(",");
        // alert(parseFloat(pt[0]));
        // alert(parseFloat(pt[1]));
        var point = new BMap.Point(parseFloat(pt[0]), parseFloat(pt[1]));
        map.centerAndZoom(point, 12);
        var marker = new BMap.Marker(point);// 创建标注
        map.addOverlay(marker);             // 将标注添加到地图中

        marker.addEventListener("dragend", function(e) {
            // alert("当前位置：" + e.point.lng + ", " + e.point.lat);
            $('#Coordinate').val(e.point.lng + ", " + e.point.lat);
        });

    } else {

        var point = new BMap.Point(116.331398, 39.897445);
        map.centerAndZoom(point, 12);

        function myFun(result) {
            var cityName = result.name;
            map.setCenter(cityName);
        }
        var myCity = new BMap.LocalCity();
        myCity.get(myFun);
    }



    map.addEventListener("click", function (e) {
        // alert(e.point.lng + "," + e.point.lat);
        map.clearOverlays();
        var marker = new BMap.Marker(e.point);// 创建标注
        map.addOverlay(marker);  // 将标注添加到地图中
        marker.enableDragging();

        var p = marker.getPosition();       //获取marker的位置
        // alert("marker的位置是" + p.lng + "," + p.lat);
        $('#Coordinate').val(p.lng + "," + p.lat);

        marker.addEventListener("dragend", function (e) {
            // alert("当前位置：" + e.point.lng + ", " + e.point.lat);
            $('#Coordinate').val(e.point.lng + ", " + e.point.lat);
        })
    });



</script>

    <script>
        function SetThumbnail() {
            var fileUrl = $("#fileList .item.active").attr("data-file");
            $('#WeiXingCode').val(fileUrl);
            $('#fileManagerModal').modal('hide');
        }

        function onBegin() {
            $("#btnSave i").removeClass("fa-save").addClass("fa-spinner fa-spin")
        }
        function onComplete() {
            $("#btnSave i").removeClass("fa-spinner fa-spin").addClass("fa-save")
        }

        function onBegin1() {
            $("#btnSave1 i").removeClass("fa-save").addClass("fa-spinner fa-spin")
        }
        function onComplete1() {
            $("#btnSave1 i").removeClass("fa-spinner fa-spin").addClass("fa-save")
        }

        function onSuccess(data) {
            Common.ShowBox(data.Status, data.Message, "@ViewBag.Title");
            //  debugger;
        }
       

   
       $.validator.addMethod('qq', function(value, element)
       {
           if(value.length>0)
               return /^[1-9][0-9]{4,9}$/.test(value)
           return true;
       });
       $.validator.unobtrusive.adapters.addBool("qq");

       $.validator.addMethod('chinamobile', function (value, element) {
           if (value.length > 0)
               return /^0{0,1}(13[0-9]|15[7-9]|153|156|170|178|18[0-9])[0-9]{8}$/.test(value)
           return true;
       });

       $.validator.unobtrusive.adapters.addBool("chinamobile");

       $.validator.addMethod('coordinate', function (value, element) {
           if (value.length > 0)
               return /^[0-9]+(\.[0-9]+),[0-9]+(\.[0-9]+)$/.test(value)
           return true;
       });

       $.validator.unobtrusive.adapters.addBool("coordinate");
      
        $(function () {
          
            $("#btnWeiXingCode").on("click", function () {
                $('#fileManagerModal').modal();
                $("#selectImage").unbind('click');
                $("#selectImage").bind("click", function () {
                    SetThumbnail();
                });
            });

            $('[data-toggle="popover"]').popover()

        });
    </script>
}